package com.lvmama.task.service.dao;


import com.lvmama.task.common.dao.BaseIbatisDAO;
import com.lvmama.task.common.vo.Task;

import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.<p/>
 * User: troy-kou<p/>
 * Date: 14-1-3<p/>
 * Time: 上午10:59<p/>
 * Email:kouhongyu@163.com<p/>
 */
public class TaskDAO extends BaseIbatisDAO {

    public Long getTaskCount(Map<String, Object> paramMap) {
        return (Long) super.queryForObject("TASK.selectTaskCount", paramMap);
    }

    public List<Task> getTaskList(Map<String, Object> paramMap) {
        //$_endRow$ - $_startRow$
        Integer startRow = (Integer) paramMap.get("_startRow");
        Integer endRow = (Integer) paramMap.get("_endRow");

        Integer startNum = startRow - 1;
        Integer pageSize = endRow - startRow + 1;

        paramMap.put("startNum", startNum);
        paramMap.put("pageSize", pageSize);

        return super.queryForListForReport("TASK.selectTaskList", paramMap);
    }
    
    public List<Task> getTaskListByInTaskId(String taskIds) {
    	return super.queryForList("TASK.selectTaskListByInTaskId", taskIds);
    }

    public Long insertTask(Task task) {
        return (Long) super.insert("TASK.insertTask", task);
    }

    public int updateTask(Task task) {
        return super.update("TASK.updateTask", task);
    }

    public int updateTaskRuntime(Task task) {
        return super.update("TASK.updateTaskRuntime", task);
    }

    public Task getTask(Long taskId) {
        return (Task) super.queryForObject("TASK.selectTask", taskId);
    }

    public void delTask(Long taskId) {
        super.delete("TASK.delete", taskId);
    }
}
